package com.dy.opencvandroid;

import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import java.io.File;

import jp.co.cyberagent.android.gpuimage.GPUImage;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageSepiaToneFilter;

/**
 * Created by gongdongyang 2019/6/18
 * Describe:
 */
public class CameraActivity extends AppCompatActivity {

    private String mImageUrl = "/storage/emulated/0/photos/20190613222903.jpg";
    private GLSurfaceView gpuImageView;

    private GPUImage gpuImage;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_camera);

        //Uri imageUri = ...;
        gpuImage = new GPUImage(this);
        gpuImage.setGLSurfaceView((GLSurfaceView) findViewById(R.id.surfaceView));
        gpuImage.setImage(new File(mImageUrl)); // this loads image on the current thread, should be run in a thread
        gpuImage.setFilter(new GPUImageSepiaToneFilter());

        gpuImage.saveToPictures("GPUImage", "ImageWithFilter.jpg", null);

    }
}
